package servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.sql.SQLException;

import dom.admindom;
import dom.redom;

@WebServlet(name = "adminServlet")
public class adminServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String flage = request.getParameter("fl");
        switch (flage) {
            case "1": //管理员注册用户
                redom re=new redom();
                re.setUserid(request.getParameter("id"));
                re.setName(request.getParameter("xm"));
                re.setPassword(request.getParameter("mm"));
                re.setNumber(request.getParameter("nu"));
                re.registered(re.getUserid(), re.getName(), re.getPassword(), re.getNumber());

            case "2":
                admindom ad = new admindom();
                ad.setUserid(request.getParameter("id"));
                try {
                    ad.logOutUser(ad.getUserid());//用户注销
                } catch (SQLException e) {
                    e.printStackTrace();
                }

            case "3"://添加管理员
                admindom add = new admindom();
                add.setName(request.getParameter("name"));
                add.setNumber(request.getParameter("number"));
                try {
                    add.addadmin(add.getName(),add.getNumber());
                } catch (SQLException e) {
                    e.printStackTrace();
                }
            case "4":


        }
    }

}
